package com.nsu.evaluation.Interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.nsu.evaluation.common.Const;


@SuppressWarnings("all")

/**
 * @describe 登录权限控制
 * 
 * @author Administrator
 *
 * @createTime 2017年9月6日17:03:20	
 */
public class AuthInterceptor  implements HandlerInterceptor{

	@Override
	/** 后处理 */
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception e) throws Exception {
		
	}

	@Override
	/** 返回处理 */
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView model) throws Exception {
		
	}

	@Override
	/** 预处理 */
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		String islogin =  (String)request.getSession().getAttribute(Const.ISLOGIN);   
        if (!"YES".equals(islogin)) {  
        	response.sendRedirect("/mbkmanage/login");  
            return false;  
        } else {
        	return true;
        }
	}

}
